package cn.wolfcode.car.service.impl;

import cn.wolfcode.car.domain.Log;
import cn.wolfcode.car.mapper.LogMapper;
import cn.wolfcode.car.qo.LogQueryObject;
import cn.wolfcode.car.service.ILogService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class LogServiceImpl implements ILogService {
    @Autowired
    private LogMapper logMapper;

    @Override
    public int delete(Long id) {
        return 0;
    }

    @Override
    public int save(Log record) {
        return logMapper.insert(record);
    }

    @Override
    public Log get(Long id) {
        return null;
    }

    @Override
    public PageInfo<Log> list(LogQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<Log> list = logMapper.selectForQo(qo);
        return new PageInfo<>(list);
    }

    @Override
    public int update(Log record) {
        return logMapper.updateByPrimaryKey(record);
    }

    @Override
    public List<Log> listAll() {
        return logMapper.selectAll();
    }
}
